package com.xy.biz.uc.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.biz.uc.domain.bo.PositionBO;
import com.xy.biz.uc.domain.po.PositionPO;
import com.xy.biz.uc.domain.query.PositionQuery;
import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.uc.domain.resp.GetPositionResponse;
import com.xy.biz.uc.domain.req.SavePositionRequest;
import com.xy.biz.uc.domain.req.ListPositionRequest;

/**
 * 
 * 
 * @author zgy
 * @date 2021-9-23
 */
public class PositionConverter {
	
	public static PositionPO toPO(PositionBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new PositionPO(), true);
	}
	
	public static List<PositionPO> toPO(Collection<PositionBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new PositionPO(), true);
	}
	
	public static PositionBO fromPO(PositionPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new PositionBO());
	}
	
	public static List<PositionBO> fromPO(Collection<PositionPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new PositionBO());
	}
	
	public static PositionBO toBO(SavePositionRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new PositionBO(), true);
	}
	
	public static List<PositionBO> toBO(Collection<SavePositionRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new PositionBO(), true);
	}
	
	public static GetPositionResponse toResponse(PositionBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetPositionResponse());
	}
	
	public static List<GetPositionResponse> toResponse(Collection<PositionBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetPositionResponse());
	}
	
	public static PositionQuery toQuery(ListPositionRequest source) {
		if(null == source) {
			return null;
		}
		PositionQuery target = new PositionQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
